perm filename DCOPY.PAL[RSX,ARG] blob
sn#542451 filedate 1980-10-30 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00004 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 Program to copy a disk image to & from the 10
C00014 00003 VT05 I/O routines
C00016 00004 Data & Constants
C00018 ENDMK
C⊗;
;Program to copy a disk image to & from the 10
.INSRT STUFF.PAL[11,ARG]
BUF1 = 10000
BUF2 = 40000
.=1000
BUFPT: 0 ;Where the 10 will look for the disk buffer
DRVNUM: 0 ;Which disk drive we're to use
DOIT: 0 ;Set when drive number is valid
START: RESET
MOV #1000,SP ;Set up the stack
MOV #BEGMES,R1 ;Tell world who we are
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
CLR DOIT
LOOP: CLR BUFPT
1$: TST DOIT ;Wait until 10's ready
BEQ 1$
MOV DRVNUM,R0 ;Get desired drive #
BIC #177774,R0
ASH #13.,R0 ;Shift drive # to high order bits
2$: TSTB RKCS ;Make sure drive is ready
BPL 2$ ; Nope - keep waiting
MOV R0,RKDA ;Select drive, cyl 0, surface 0, sector 0
MOV DOIT,R0 ;See whether we're reading or writing
CLR DOIT
CMP #1,R0 ;Reading?
BEQ READ ; Yes
JMP WRITE ; No
READ: MOV RKDA,R2 ;Save Disk address register
MOV #BUF1,RKBA ;Fill up both buffers
MOV #-30000,RKWC ;Set word count
MOV #5,RKCS ;Go read in the first two cylinders
1$: TSTB RKCS ;Wait for disk operation to finished
BPL 1$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BPL 2$ ; Skip ahead if everything's ok
MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
2$: MOV #BUF1,RKBA ;Now let's confirm that the read was ok
MOV R2,RKDA ;Restore old disk address register
MOV #-30000,RKWC ;Set word count
MOV #13,RKCS ;Go read check the first two cylinders
3$: TSTB RKCS ;Wait for disk operation to finish
BPL 3$ ; Nope - keep waiting
MOV #201.,R5 ;# of cylinders more to read
MOV #BUF1,BUFPT ;Tell 10 data's ready for it now
RLOOP: TST BUFPT ;Wait til 10's done with buffer
BNE RLOOP
1$: TSTB RKCS ;See if last disk operation has finished
BPL 1$ ; Nope - wait
TST RKCS ;See that last operation didn't cause an error
BPL 3$ ; Skip ahead if everything's ok
2$: MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
3$: MOV #BUF2,BUFPT ;Start 10 on 2nd buffer while we refill 1st
MOV #BUF1,R4
MOV R4,RKBA ;Filling up buffer 1
MOV RKDA,R2 ;Save Disk address register
MOV #-14000,RKWC ;Set word count
MOV #5,RKCS ;Go read in the next cylinder
4$: TSTB RKCS ;Wait for disk operation to finish
BPL 4$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BMI 2$ ; Complain if it did
MOV #BUF1,RKBA ;Now let's confirm that the read was ok
MOV R2,RKDA ;Restore old disk address register
MOV #-14000,RKWC ;Set word count
MOV #13,RKCS ;Go read check the cylinder
DEC R5 ;Check if that's the last one
BEQ RLBUF ; & get ready to quit of so
RB2LP: TST BUFPT ;Wait til 10's done with second buffer
BNE RB2LP
1$: TSTB RKCS ;See if last disk operation has finished
BPL 1$ ; Nope - wait
TST RKCS ;See that last operation didn't cause an error
BPL 3$ ; Skip ahead if everything's ok
2$: MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
3$: MOV #BUF1,BUFPT ;Start 10 on 1st buffer while we refill 2nd
MOV RKDA,R2 ;Save Disk address register
MOV #BUF2,R4
MOV R4,RKBA ;Filling up buffer 2
MOV #-14000,RKWC ;Set word count
MOV #5,RKCS ;Go read in the next cylinder
4$: TSTB RKCS ;Wait for disk operation to finish
BPL 4$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BMI 2$ ; Complain if it did
MOV #BUF2,RKBA ;Now let's confirm that the read was ok
MOV R2,RKDA ;Restore old disk address register
MOV #-14000,RKWC ;Set word count
MOV #13,RKCS ;Go read check the cylinder
DEC R5 ;Check if more cylinders to be read
BNE RLOOP
RLBUF: TST BUFPT ;Wait til 10's done with previous buffer
BNE RLBUF
1$: TSTB RKCS ;See if disk operation has finished
BPL 1$ ; Nope - wait
TST RKCS ;See that last operation didn't cause an error
BPL 2$ ; Skip ahead if everything's ok
MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
2$: MOV R4,BUFPT ;Start 10 on last buffer
3$: TST BUFPT ;Wait til 10's done with buffer
BNE 3$
JMP LOOP ;We're all done now
WRITE: MOV #BUF1,BUFPT ;Tell 10 to start filling buffer 1
MOV #203.,R5 ;# of cylinders we'll be writing
MOV #11,RKCS ;Do a seek operation to get ready
WLOOP: TST BUFPT ;Wait til 10's done with buffer
BNE WLOOP
1$: TSTB RKCS ;See if last disk operation has finished
BPL 1$ ; Nope - wait
TST RKCS ;See that last operation didn't cause an error
BPL 3$ ; Skip ahead if everything's ok
2$: MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
3$: MOV #BUF2,BUFPT ;Start 10 on 2nd buffer while we empty 1st
MOV RKDA,R2 ;Save Disk address register
MOV #BUF1,RKBA ;Writing out buffer 1
MOV #-14000,RKWC ;Set word count
MOV #3,RKCS ;Go write out the next cylinder
4$: TSTB RKCS ;Wait for disk operation to finish
BPL 4$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BMI 2$ ; Complain if it did
MOV #BUF1,RKBA ;Now let's confirm that the write was ok
MOV R2,RKDA ;Restore old disk address register
MOV #-14000,RKWC ;Set word count
MOV #7,RKCS ;Go write check the cylinder
DEC R5 ;Check if that's the last one
BEQ WLBUF ; Yup go quit
WB2LP: TST BUFPT ;Wait til 10's done with second buffer
BNE WB2LP
1$: TSTB RKCS ;See if last disk operation has finished
BPL 1$ ; Nope - wait
TST RKCS ;See that last operation didn't cause an error
BPL 3$ ; Skip ahead if everything's ok
2$: MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
3$: MOV #BUF1,BUFPT ;Start 10 on 1st buffer while we empty 2nd
MOV RKDA,R2 ;Save Disk address register
MOV #BUF2,RKBA ;Writing out buffer 2
MOV #-14000,RKWC ;Set word count
MOV #3,RKCS ;Go write out the next cylinder
4$: TSTB RKCS ;Wait for disk operation to finish
BPL 4$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BMI 3$ ; Complain if it did
MOV #BUF2,RKBA ;Now let's confirm that the write was ok
MOV R2,RKDA ;Restore old disk address register
MOV #-14000,RKWC ;Set word count
MOV #7,RKCS ;Go write check the cylinder
DEC R5 ;Check if that's the last one
BNE WLOOP ; Nope - keep going
WLBUF: TST BUFPT ;Wait til 10's done with previous buffer
BNE WLBUF
1$: TSTB RKCS ;Wait for disk operation to finish
BPL 1$ ; Nope - keep waiting
TST RKCS ;See that last operation didn't cause an error
BPL 2$ ; Skip ahead if everything's ok
MOV #1,BUFPT ;Tell 10 we had an error
MOV #ERRMES,R1 ;Complain about it too
JSR PC,OUTSTR
MOV #CRLF,R1
JSR PC,OUTSTR
BPT ;Punt
2$: MOV #2,BUFPT ;Tell 10 last buffer was okay
3$: TST BUFPT ;Wait til 10's done with buffer
BNE 3$
JMP LOOP ;We're all done now
;VT05 I/O routines
OUTSTR: MOVB (R1)+,R0 ;Get next char
BEQ 1$ ;If done - quit
JSR PC,OUTCHR ;Print it
BR OUTSTR
1$: JSR PC,OUTCHR ;Print a couple nulls
JSR PC,OUTCHR
; JMP OUTCHR
OUTCHR: TST OUTSW ;Who does it go to?
BEQ 2$
1$: TSTB KBOS ;VT05 ready?
BPL 1$ ;Loop til it is
MOVB R0,KBOR ;Print the char
RTS PC
2$: TSTB OREG ;Console ready?
BNE 2$ ;Wait til it is
MOVB R0,OREG ;Output char
RTS PC
INCHR: TST OUTSW ;Where does it come from?
BEQ 1$
TSTB KBIS ;Anything typed on VT05?
BPL 2$ ; No
MOVB KBIR,R0 ; Read the char
RTS PC
1$: TSTB IREG ;Anything from the 10?
BEQ 2$ ; No
MOVB IREG,R0 ; Fetch the char
CLRB IREG
RTS PC
2$: CLR R0 ;No input
RTS PC
;Data & Constants
BEGMES: .ASCII /πDisk Copy Program/
CRLF: .BYTE 12,15,0
ERRMES: .ASCIZ /πDisk Errorπ/
.END START